package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bwie.mapper.TbCarMapper;
import com.bwie.pojo.TbCar;
import com.bwie.service.TbCarService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class TbCarServiceImpl implements TbCarService {
    @Autowired
    private TbCarMapper tbCarMapper;
    @Override
    public R selectCar(PageInfoVo pageInfoVo) {
        Page<TbCar> tbCarPage = new Page<>(pageInfoVo.getPageNum(),pageInfoVo.getPageSize());
        Page<TbCar> carPage = tbCarMapper.selectPage(tbCarPage, new QueryWrapper<>());
        return R.OK(carPage);
    }

    @Override
    public R addList(TbCar tbCar) {
        tbCar.setEntryTime(new Date());
        tbCar.setPrice("2");
        int insert = tbCarMapper.insert(tbCar);
        return R.OK(insert);
    }
}
